//
//  ChooseImageCell.swift
//  Employee
//
//  Created by swordjoy on 2017/3/28.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import UIKit

class ChooseImageCell: UICollectionViewCell {
  static var identifier = "ChooseImageCell.swordjoy"
  
  var addPhotoClosure: VoidClosure?
  
  fileprivate var addButton: UIButton!
  
  override init(frame: CGRect) {
    super.init(frame: frame)
    backgroundColor = UIColor.clear
    create()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
}

// MARK: - action

extension ChooseImageCell {
  @objc fileprivate func addPhotoAction() {
    guard let closure = addPhotoClosure  else { return }
    closure()
  }
}

// MARK: - fileprivate

extension ChooseImageCell {
  fileprivate func create() {
    addButton = UIButton()
    contentView.addSubview(addButton)
    addButton.backgroundColor = UIColor.hex("#f1f4f4")
    let image = UIImage(named: "upload-icon")
    addButton.setImage(image, for: .normal)
    addButton.addTarget(self, action: #selector(addPhotoAction), for: .touchUpInside)
    addButton.snp.makeConstraints { (make) in
      make.left.right.top.bottom.equalToSuperview()
    }
  }
}
